/**
 * 详情对话框
 */
var DbNoticeInfoDlg = {
    data: {
        id: "",
        content: "",
        department: "",
        system: "",
        state: "",
        xxContent: "",
        userId: "",
        revision: "",
        createdBy: "",
        createdTime: "",
        updatedBy: "",
        updatedTime: ""
    }
};


layui.use(['form', 'admin', 'ax', 'laydate', 'upload', 'formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    $('#reload').click(function () {
        //关掉对话框
        admin.closeThisDialog();
    })


    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/dbNotice/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    // if (result.data.state == 0) {
    //     result.data.state = "未读"
    // } else if (result.data.state == 1) {
    //     result.data.state = "已读"
    // }
    if (result.data.spState == 0) {
        result.data.spState = "未审批"
    } else if (result.data.spState == 1) {
        result.data.spState = "已通过"
    } else if (result.data.spState == 2) {
        result.data.spState = "已通过,开发中"
    } else if (result.data.spState == 3) {
        result.data.spState = "已驳回"
    } else if (result.data.spState == 4) {
        result.data.spState = "开发完成"
    }

    if (result.data.serviceType == 1) {
        result.data.serviceType = "数据库服务"
    }
    // else if (result.data.serviceType == 2) {
    //     result.data.serviceType = "平台类型"
    // } else if (result.data.serviceType == 3) {
    //     result.data.serviceType = "其他类型"
    // }
    form.val('dbNoticeForm', result.data);


    //表单提交事件
    // form.on('submit(btnSubmit)', function (data) {
    //     var ajax = new $ax(Feng.ctxPath + "/dbNotice/editItem", function (data) {
    //         Feng.success("更新成功！");
    //         //传给上个页面，刷新table用
    //         admin.putTempData('formOk', true);
    //         //关掉对话框
    //         admin.closeThisDialog();
    //     }, function (data) {
    //         Feng.error("更新失败！" + data.responseJSON.message)
    //     });
    //     ajax.set(data.field);
    //     ajax.start();
    //
    //     return false;
    // });

    /**
     * 文本域高度自适应
     */
    //jQuery实现textarea高度根据内容自适应
    $.fn.extend({
        txtaAutoHeight: function () {
            return this.each(function () {
                var $this = $(this);
                if (!$this.attr('initAttrH')) {
                }
                setAutoHeight(this).on('input', function () {
                    setAutoHeight(this);
                });
            });

            function setAutoHeight(elem) {
                var $obj = $(elem);
                return $obj.css({height: $obj.attr('initAttrH'), 'overflow-y': 'hidden'}).height(elem.scrollHeight);
            }
        }
    });
    //调用
    $(function () {
        $("#remark").txtaAutoHeight();
    });

});